package clientserver;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ClienteVista {

	private JFrame janela;
	private JPanel painel;
	private int largura,altura;
	private Dimension d;
	private Insets i;
	private JTextArea texto1;
	private JTextArea texto2;
	private JScrollPane scrollPane1,scrollPane2;
	private GridBagConstraints c;
	
	public ClienteVista() {
		janela=new JFrame("Chat");
		painel=new JPanel();
		texto1=new JTextArea();
		scrollPane1=new JScrollPane(texto1);
		texto2=new JTextArea();
		scrollPane2=new JScrollPane(texto2);
		c = new GridBagConstraints();
	
		//configura tamanho e posicao da janela;
		d=Toolkit.getDefaultToolkit().getScreenSize();
		i=Toolkit.getDefaultToolkit().getScreenInsets(janela.getGraphicsConfiguration());
		largura=(d.width-i.left-i.right);
		altura=(d.height-i.top-i.bottom);
		janela.setSize(largura/2,altura/2);
		
		scrollPane1.setPreferredSize(new Dimension((int)d.getWidth(),(int)d.getHeight()/2));
		scrollPane2.setPreferredSize(new Dimension((int)(d.getWidth()),(int)(d.getHeight()/2)));
		
		painel.setLayout(new GridBagLayout()); 
		painel.setPreferredSize(new Dimension(janela.getWidth(), janela.getHeight()));
		
		c.gridx=0;
		c.gridy=0;
		c.weightx=1;
		c.weighty=0.95;
		c.fill=GridBagConstraints.BOTH;
		painel.add(scrollPane1,c);
		
		c.gridx=0;
		c.gridy=1;
		c.weightx=1;
		c.weighty=0.05;
		c.fill=GridBagConstraints.BOTH;
		painel.add(scrollPane2,c);
		
		janela.setLocation(largura/2-janela.getWidth()/2,altura/2-janela.getHeight()/2);
		janela.add(painel);
		janela.setVisible(true);
		janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public JTextArea getTextArea(){
		return texto1;
	}
	
	public JTextArea getTextArea2(){
		return texto2;
	}
	
	public JFrame getJanela(){
		return janela;
	}
}


